home *** CD-ROM | disk | FTP | other *** search
/ Clickx 47 / Clickx 47.iso / assets / software / sswitchxp152.exe / source / SpeedswitchXP / MachOptions.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2006-07-13  |  5.2 KB  |  166 lines

  1. /*
  2.    SpeedswitchXP V1.5
  3.    - Windows XP CPU Frequency Control for Notebooks -
  4.  
  5.    Copyright(c) 2002-2005 Christian Diefer
  6.  
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License version 2 as 
  9.    published by the Free Software Foundation.
  10.    
  11.    This program is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.    
  16.    You should have received a copy of the GNU General Public License
  17.    along with this program; if not, write to the Free Software
  18.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20.  
  21. #define _UNICODE
  22.  
  23. #include "stdafx.h"
  24. #include "SpeedswitchXP.h"
  25. #include "MachOptions.h"
  26. #include "speedswitch.h"
  27.  
  28. #define TOOLTIP_ID 1
  29.  
  30. // CMachOptions dialog
  31.  
  32. IMPLEMENT_DYNAMIC(CMachOptions, CDialog)
  33. CMachOptions::CMachOptions(CWnd* pParent /*=NULL*/)
  34.     : CDialog(CMachOptions::IDD, pParent)
  35.   , m_iMinSleepAC(0)
  36.   , m_iMinSleepDC(0)
  37.   , m_iRedLatSleepAC(0)
  38.   , m_iRedLatSleepDC(0)
  39.   , m_iDozeTimeoutAC(0)
  40.   , m_iDozeTimeoutDC(0)
  41.   , m_iDozeS4TimeoutAC(0)
  42.   , m_iDozeS4TimeoutDC(0)
  43.   , m_iMinThrottleAC(0)
  44.   , m_iMinThrottleDC(0)
  45. { }
  46.  
  47. CMachOptions::~CMachOptions()
  48. { }
  49.  
  50. void CMachOptions::DoDataExchange(CDataExchange* pDX)
  51. {
  52.   CDialog::DoDataExchange(pDX);
  53.   DDX_CBIndex(pDX, IDC_COMBO3, m_iMinSleepAC);
  54.   DDX_CBIndex(pDX, IDC_COMBO4, m_iMinSleepDC);
  55.   DDX_CBIndex(pDX, IDC_COMBO7, m_iRedLatSleepAC);
  56.   DDX_CBIndex(pDX, IDC_COMBO8, m_iRedLatSleepDC);
  57.   DDX_Text(pDX, IDC_EDIT1, m_iDozeTimeoutAC);
  58.   DDX_Text(pDX, IDC_EDIT2, m_iDozeTimeoutDC);
  59.   DDX_Text(pDX, IDC_EDIT3, m_iDozeS4TimeoutAC);
  60.   DDX_Text(pDX, IDC_EDIT7, m_iDozeS4TimeoutDC);
  61.   DDX_Text(pDX, IDC_EDIT11, m_iMinThrottleAC);
  62.   DDX_Text(pDX, IDC_EDIT12, m_iMinThrottleDC);
  63. }
  64.  
  65. BOOL CMachOptions::OnInitDialog()
  66. {
  67.     CDialog::OnInitDialog();
  68.  
  69.   CString s1;
  70.  
  71.   s1.LoadStringW( IDS_MACH1 );
  72.   addToolTip( 0, IDC_COMBO3, s1 );
  73.   addToolTip( 1, IDC_COMBO4, s1 );
  74.  
  75.   s1.LoadStringW( IDS_MACH2 );
  76.   addToolTip( 2, IDC_COMBO7, s1 );
  77.   addToolTip( 3, IDC_COMBO8, s1 );
  78.  
  79.   s1.LoadStringW( IDS_MACH3 );
  80.   addToolTip( 4, IDC_EDIT1, s1 );
  81.   addToolTip( 5, IDC_EDIT2, s1 );
  82.  
  83.   s1.LoadStringW( IDS_MACH4 );
  84.   addToolTip( 6, IDC_EDIT3, s1 );
  85.   addToolTip( 7, IDC_EDIT7, s1 );
  86.  
  87.   s1.LoadStringW( IDS_MACH5 );
  88.   addToolTip( 8, IDC_EDIT11, s1 );
  89.   addToolTip( 9, IDC_EDIT12, s1 );
  90.  
  91.   return TRUE;
  92. }
  93.  
  94. BOOL CMachOptions::PreTranslateMessage( MSG* pMsg ) 
  95. {
  96.   for( int i=0; i<10; i++ )
  97.     m_tToolTip[i].RelayEvent( pMsg );
  98.  
  99.   return CDialog::PreTranslateMessage( pMsg );
  100. }
  101.  
  102. BEGIN_MESSAGE_MAP(CMachOptions, CDialog)
  103. END_MESSAGE_MAP()
  104.  
  105.  
  106. // CMachOptions message handlers
  107. void CMachOptions::setVars()
  108. {
  109.   m_iMinSleepAC = internalPolicy.mach.MinSleepAc;
  110.   m_iMinSleepDC = internalPolicy.mach.MinSleepDc;
  111.   m_iRedLatSleepAC = internalPolicy.mach.ReducedLatencySleepAc;
  112.   m_iRedLatSleepDC = internalPolicy.mach.ReducedLatencySleepDc;
  113.   m_iDozeTimeoutAC = internalPolicy.mach.DozeTimeoutAc;
  114.   m_iDozeTimeoutDC = internalPolicy.mach.DozeTimeoutDc;
  115.   m_iDozeS4TimeoutAC = internalPolicy.mach.DozeS4TimeoutAc;
  116.   m_iDozeS4TimeoutDC = internalPolicy.mach.DozeS4TimeoutDc;
  117.   m_iMinThrottleAC = internalPolicy.mach.MinThrottleAc;
  118.   m_iMinThrottleDC = internalPolicy.mach.MinThrottleDc;
  119. }
  120.  
  121. void CMachOptions::getVars()
  122. {
  123.   if( m_iMinThrottleAC<0 || m_iMinThrottleAC>100 )
  124.     m_iMinThrottleAC = internalPolicy.mach.MinThrottleAc;
  125.  
  126.   if( m_iMinThrottleDC<0 || m_iMinThrottleDC>100 )
  127.     m_iMinThrottleDC = internalPolicy.mach.MinThrottleDc;
  128.  
  129.   if( m_iMinSleepAC != internalPolicy.mach.MinSleepAc
  130.   ||  m_iMinSleepDC != internalPolicy.mach.MinSleepDc
  131.   ||  m_iRedLatSleepAC != internalPolicy.mach.ReducedLatencySleepAc
  132.   ||  m_iRedLatSleepDC != internalPolicy.mach.ReducedLatencySleepDc
  133.   ||  m_iDozeTimeoutAC != internalPolicy.mach.DozeTimeoutAc
  134.   ||  m_iDozeTimeoutDC != internalPolicy.mach.DozeTimeoutDc
  135.   ||  m_iDozeS4TimeoutAC != internalPolicy.mach.DozeS4TimeoutAc
  136.   ||  m_iDozeS4TimeoutDC != internalPolicy.mach.DozeS4TimeoutDc
  137.   ||  m_iMinThrottleAC != internalPolicy.mach.MinThrottleAc
  138.   ||  m_iMinThrottleDC != internalPolicy.mach.MinThrottleDc )
  139.     power = TRUE;
  140.   else
  141.   {
  142.     power = FALSE;
  143.     return;
  144.   }
  145.  
  146.   internalPolicy.mach.MinSleepAc = (SYSTEM_POWER_STATE)m_iMinSleepAC;
  147.   internalPolicy.mach.MinSleepDc = (SYSTEM_POWER_STATE)m_iMinSleepDC;
  148.   internalPolicy.mach.ReducedLatencySleepAc = (SYSTEM_POWER_STATE)m_iRedLatSleepAC;
  149.   internalPolicy.mach.ReducedLatencySleepDc = (SYSTEM_POWER_STATE)m_iRedLatSleepDC;
  150.   internalPolicy.mach.DozeTimeoutAc = m_iDozeTimeoutAC;
  151.   internalPolicy.mach.DozeTimeoutDc = m_iDozeTimeoutDC;
  152.   internalPolicy.mach.DozeS4TimeoutAc = m_iDozeS4TimeoutAC;
  153.   internalPolicy.mach.DozeS4TimeoutDc = m_iDozeS4TimeoutDC;
  154.   internalPolicy.mach.MinThrottleAc = m_iMinThrottleAC;
  155.   internalPolicy.mach.MinThrottleDc = m_iMinThrottleDC;
  156. }
  157.  
  158. void CMachOptions::addToolTip( int no, int id, CString str )
  159. {
  160.   CWnd* wnd = GetDlgItem( id );
  161.   CRect rect; 
  162.   wnd->GetClientRect( rect );
  163.   m_tToolTip[no].Create( wnd );
  164.   m_tToolTip[no].AddTool( wnd, str, rect, TOOLTIP_ID );
  165. }
  166.